package com.tengju.bff.interfaces.miniprogram.user;

import com.tengju.bff.interfaces.miniprogram.user.facade.UserInfoFacade;
import com.tengju.bff.interfaces.miniprogram.user.vo.UserInfoVo;
import com.tengju.bff.interfaces.shared.ApiResponse;
import com.tengju.bff.interfaces.shared.servlet.ServletContextUtil;
import com.tengju.bff.interfaces.shared.servlet.UserServletContext;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: 用户信息服务
 * @since: 2021/12/30 10:13 上午
 * @author: xiajichen
 */
@RestController
@Api(tags = "用户信息服务")
@RequestMapping(value = "miniprogram/user/")
@Slf4j
public class UserController {

    private UserInfoFacade userInfoFacade;

    public UserController(UserInfoFacade userInfoFacade) {
        this.userInfoFacade = userInfoFacade;
    }

    @RequestMapping(value = "getUserInfo", method = RequestMethod.GET)
    public ApiResponse<UserInfoVo> getUserInfo() {
        UserServletContext servletContext = ServletContextUtil.getServletContext();
        return ApiResponse.newSuccess(userInfoFacade.getUserInfoByFrom(servletContext.getIdCode(), servletContext.getFrom()));
    }

}
